package com.zelin.config;

import org.springframework.cloud.gateway.filter.factory.StripPrefixGatewayFilterFactory;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by WF on 2020/11/2 11:20
 * 定义路由规则
 */
@Configuration
public class MyGatewayConfig {
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder rb){

        return rb.routes()
                    .route("gateway-api2",
                        r->r.path("/product-serv2/**")
                            .filters(f->f.stripPrefix(1))
                            .uri("http://localhost:8081"))
                            .build();
    }
}
